import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { GameController } from "../../mvc/GameController";
import { ObjCreate } from "../common/ObjCreate";
import { GTextArea } from "../../../../com/mui/controls/GTextArea";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { ResFileConst } from "../../resource/ResFileConst";
import { Alert } from "../../../../com/mui/controls/Alert";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { TextBox } from "./TextBox";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
import { Cache } from "../../cache/Cache";
import { MoneyUtil } from "../common/util/MoneyUtil";
import { Vector } from "../../../../__AS3__/vec/Vector";
type int = number;
//class PackWallet
    
    export  class PackWallet extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this._vcText = new Vector.<String>();
            setSize(230, 463);
            titleHeight = 26;
            title = Language.getString(43804);
            this.layer = GameController.pack.view as BaseWindow;
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createSpBannerAndBg(18, 39, 195, 301, Language.getString(43805), this);
            this._recordsTextArea = new GTextArea();
            ObjCreate.setObjAttri(this._recordsTextArea, 25, 71, 186, 268, this);
            this._recordsTextArea.editable = false;
            this._recordsTextArea.styleName = "GTextArea";
            this._recordsTextArea.textField.filters = [FilterConst.glowFilter];
            this._recordsTextArea.wordWrap = true;
            this.createIcon(1, "Yuanbao");
            this._goldTextBox = this.createTextBox(1);
            var loc1=this.createBtn(1, ResFileConst.PackRechange, Language.getString(43806));
            this.createIcon(2, "Yuanbao_bind");
            this._goldBindTextBox = this.createTextBox(2);
            this.createBtn(2, ResFileConst.PackAdd, Language.getString(43807));
            this.createIcon(3, "Tongqian");
            this._coinTextBox = this.createTextBox(3);
            this.createBtn(3, ResFileConst.PackAdd, Language.getString(43808));
            this.createIcon(4, "Tongqian_bind");
            this._coinBindTextBox = this.createTextBox(4);
            this.createBtn(4, ResFileConst.PackAdd, Language.getString(43809));
            loc1.addEventListener(flash.events.MouseEvent.CLICK, this.onGoldBtnClick);
            return;
        }

        /* internal  */onGoldBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            Alert.show(Language.getString(43810), null, Alert.OK | Alert.CANCEL, null, this.onClose);
            return;
        }

        /* internal  */onClose(arg1: int): void
        {
            if (arg1 == Alert.OK) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.GotoPay));
            }
            return;
        }

        /* internal  */createIcon(arg1: int, arg2: string): void
        {
            var loc1=null;
            loc1 = GlobalClass.getBitmap(arg2);
            loc1.x = 26;
            loc1.y = 350 + (arg1 - 1) * 25;
            this.addChild(loc1);
            return;
        }

        /* internal  */createTextBox(arg1: int): TextBox
        {
            var loc1=null;
            loc1 = new TextBox();
            loc1.textFieldHeight = 18;
            loc1.textFieldWidth = 95;
            loc1.bgHeight = 18;
            loc1.bgWidth = 95;
            loc1.x = 55;
            loc1.y = 350 + (arg1 - 1) * 25;
            this.addChild(loc1);
            return loc1;
        }

        /* internal  */createBtn(arg1: int, arg2: string, arg3: string): GLoadedButton
        {
            var loc1;
            (loc1 = ObjCreate.createGLoadedButton(arg2, 152, 348 + (arg1 - 1) * 25, 23, 23, this)).toolTipData = arg3;
            return loc1;
        }

        public addTips(arg1: string): void
        {
            this.htmlText = this.htmlText + (arg1 + "<br>");
            if (this.htmlText.length > 5000) 
            {
                this.htmlText = this.htmlText.slice(this.htmlText.indexOf("<br>") + 4);
            }
            if (!this.isHide) 
            {
                this.showTips();
            }
            return;
        }

        public showTips(): void
        {
            this._recordsTextArea.htmlText = "<textFormat leading=\'5\'><font color=\'#B1efff\'>" + this.htmlText + "</font></textFormat>";
            this._recordsTextArea.verticalScrollPosition = this._recordsTextArea.maxVerticalScrollPosition;
            return;
        }

        public updateMoney(): void
        {
            var loc1=Cache.instance.login.loginGame.money;
            this.setCoinAmount(loc1.coin);
            this.setCoinBindAmount(loc1.coinBind);
            this.setGoldAmount(loc1.gold);
            this.setGoldBindAmount(loc1.goldBind);
            return;
        }

        public setCoinAmount(arg1: int): void
        {
            this._coinTextBox.htmlText = MoneyUtil.getCoinHtml(arg1);
            return;
        }

        public setCoinBindAmount(arg1: int): void
        {
            this._coinBindTextBox.htmlText = MoneyUtil.getCoinHtml(arg1);
            return;
        }

        public setGoldAmount(arg1: int): void
        {
            this._goldTextBox.htmlText = MoneyUtil.getGoldHtml(arg1);
            return;
        }

        public setGoldBindAmount(arg1: int): void
        {
            this._goldBindTextBox.htmlText = MoneyUtil.getGoldHtml(arg1);
            return;
        }

        /* internal */ /* var */_maxNum: int=100;

        /* internal */ /* var */_vcText: Vector.<String>;

        /* internal */ /* var */_recordsTextArea: GTextArea;

        /* internal */ /* var */_goldTextBox: TextBox;

        /* internal */ /* var */_coinTextBox: TextBox;

        /* internal */ /* var */_goldBindTextBox: TextBox;

        /* internal */ /* var */_coinBindTextBox: TextBox;

        /* internal */ /* var */htmlText: string="";
    }
